package pratima.Singleton;

/**
 * Singleton design pattern for creating single object to class
 * 
 * @author Pratima
 */
public class Singleton {
	
	private static Singleton singletonInstance;
	public String singletonString;
	private Singleton() {
		singletonString =  "private constructor";
	}
	
	private Singleton(String singletonString) {
		this.singletonString = singletonString;
	}
	public static Singleton getSingletonInstace() {
		if(singletonInstance == null) {
			singletonInstance = new Singleton ();
			System.out.println("Singleton instance is created");
		} else {
			System.out.println("Singleton instance is not create");
		}
		return singletonInstance;
	}
	
	public static Singleton getSingletonInstace(String singletonString) {
		if(singletonInstance == null) {
			singletonInstance = new Singleton (singletonString);
			System.out.println("Singleton instance is created");
		} else {
			System.out.println("Singleton instance is not create");
		}
		return singletonInstance;
	}
}
